--- title: "L2-040 哲哲打游戏" created: 2025-11-28 tags: - 算法 --- # L2-040 哲哲打游戏 ## 题目 [L2-040 哲哲打游戏](https://pintia.cn/problem-sets/994805046380707840/exam/problems/type/7?problemSetProblemId=1386335159927652363&page=1) ![[image-cde4fe6d.png]] ## 思路分析 ![[image-c62e28cd.png]] ## 代码实现 ```cpp #include using namespace std; #define endl '\n' #define int long long using ll = long long; using ull = unsigned long long; using PII = pair; using Pll = pair; int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 }; const int inf = 0x3f3f3f3f; signed main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n,m;cin>>n>>m; vector> g(n+1); vector cundang(n+1); for(int i=1;i<=n;i++){ int k;cin>>k; g[i].push_back(i);//0号位置填充掉 while(k--){ int to;cin>>to; g[i].push_back(to); } } int cur=1; for(int i=1;i<=m;i++){ int op,val;cin>>op>>val; if(op==1){ cundang[val]=cur; cout<